Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split multi-tenancy quickstart into two projects #1493

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

tobHai
Copy link

@tobHai tobHai commented Jan 19, 2025

Fixes quarkusio/quarkus#41759

Check list:

Your pull request:

  • targets the development branch
  • uses the 999-SNAPSHOT version of Quarkus
  • has tests (mvn clean test)
  • works in native (mvn clean package -Pnative)
  • has integration/native tests (mvn clean verify -Pnative)
  • makes sure the associated guide must not be updated
  • links the guide update pull request (if needed)
  • updates or creates the README.md file (with build and run instructions)
  • for new quickstart, is located in the directory component-quickstart
  • for new quickstart, is added to the root pom.xml and README.md

I split the existing quickstart into two:

  • schema approach
  • database approach

Additionally, I used dev services for the database connections.
The only real code change I did was fixing a warning in: d939238 (#1493)

I am not sure to which guide the checklist is referring to - do I need to update another project as well?
Edit: updated the docs as well: https://github.com/quarkusio/quarkus/pull/46030/files

@yrodiere
Copy link
Member

I am not sure to which guide the checklist is referring to - do I need to update another project as well?

It refers to the Quarkus guide. The documentation.
In this case this file: https://github.com/quarkusio/quarkus/blob/main/docs/src/main/asciidoc/hibernate-orm.adoc
In particular you'll see reference to quickstarts for multitenancy here: https://github.com/quarkusio/quarkus/blob/cc10bd920755824b94437e88ac01da8651eb7ea0/docs/src/main/asciidoc/hibernate-orm.adoc?plain=1#L1085

So you'd need to:

  1. Remove that reference (it's now invalid)
  2. Introduce references to your newly introduced quickstarts in the relevant subsections
  3. Make sure any code examples mentioned in these subsections is consistent with your newly introduced quickstarts

Copy link
Member

@yrodiere yrodiere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's a nice cleanup. I added a few comments below.

Before merging, I think we'll need:

  1. Comments to be addressed/dismissed.
  2. A PR to be sent to the main Quarkus repo to make sure the documentation (hibernate-orm.adoc) is updated consistently.
  3. Ideally, all commits in this PR to be squashed into at most two: the splitting, and the addition of @PersistenceUnitExtension on tenant resolvers. EDIT: Okay maybe three if you want to keep the devservice thing separate, but that seems like it could be annoying to do properly, so I'd just squash that together in the same commit as the splitting.

I created a follow-up issue (quarkusio/quarkus#45715), but it's out of scope: just a few pre-existing problems that your PR reminded me of (thanks!).

hibernate-orm-multi-tenancy-database-quickstart/README.md Outdated Show resolved Hide resolved
hibernate-orm-multi-tenancy-database-quickstart/pom.xml Outdated Show resolved Hide resolved
hibernate-orm-multi-tenancy-database-quickstart/README.md Outdated Show resolved Hide resolved
hibernate-orm-multi-tenancy-schema-quickstart/README.md Outdated Show resolved Hide resolved
Copy link
Member

@yrodiere yrodiere Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably align this file on the docs, since that's where we'll explain the quickstart: https://quarkus.io/guides/hibernate-orm#database-approach

One thing you'll want to change compared to the docs though (and maybe update in the docs): the JDBC URL property needs to be prefixed with %prod, otherwise dev services will be disabled and Quarkus will just try to connect to that URL.

So this:

quarkus.datasource.base.jdbc.url=jdbc:postgresql://localhost:5432/quarkus_test
...
quarkus.datasource.mycompany.jdbc.url=jdbc:postgresql://localhost:5433/mycompany

Should be this instead:

%prod.quarkus.datasource.base.jdbc.url=jdbc:postgresql://localhost:5432/quarkus_test
...
%prod.quarkus.datasource.mycompany.jdbc.url=jdbc:postgresql://localhost:5433/mycompany

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, ideally the whole file should be made consistent with the one at https://quarkus.io/guides/hibernate-orm#schema-approach

Here too, the JDBC URL should be limited to the prod profile, otherwise dev services will be disabled.

Comment on lines 10 to 17
/**
* Workaround to allow launching the Quarkus application inside the IDE.
*
* @see https://github.com/quarkusio/quarkus/issues/2143
*/
@Disabled("You can enable this pseudo test to run the app in your IDE")
@QuarkusTest
public class IdeTestApp {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue appears to have been fixed. I'd suggest removing this class from both Maven modules?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably use @PersistenceUnitExtension here too?

@yrodiere
Copy link
Member

Also, I tested locally, it works great! Much better experience than the previous docker-compose setup with Maven profiles.

@yrodiere yrodiere self-assigned this Jan 20, 2025

This comment has been minimized.

@tobHai
Copy link
Author

tobHai commented Jan 30, 2025

Thanks for the detailed review - I will implement all of it soon!

@tobHai
Copy link
Author

tobHai commented Feb 1, 2025

@yrodiere I noticed an additional warning in the database quickstart:

2025-02-01 10:00:34,425 WARN [io.qua.dat.dep.dev.DevServicesDatasourceProcessor] (build-55) Unable to determine a database type for default datasource

I tried to fix it by adding: quarkus.datasource.db-kind=postgresql to the configuration but this would result in a third instance of postgresql being created - which is not what we want.

When researching I came across: quarkusio/quarkus#23563 (comment).
Does the devservice feature maybe always need a default datasource?

@tobHai tobHai force-pushed the cleanup-hibernate-multi-tenancy-examples branch 2 times, most recently from 5c1acb5 to f680d7c Compare February 1, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants